﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>
<!DOCTYPE html>
<html>
<body>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <div class="layui-form-item">

                <table>
                    <tr>
                        <td colspan="2">





                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="layui-form-item">
                                <label class="layui-form-label">测定日期</label>
                                <div class="layui-input-block">
                                    <input type="date" id="currentDate" class="layui-input">
                                </div>
                            </div>
                        </td>
                        <td>
                            <div class="layui-form-item">
                                <label class="layui-form-label">羊只耳号</label>
                                <div class="layui-input-block">
                                    <select id="earBugles">
                                        <option value="">请选择</option>
                                    </select>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="layui-form-item">
                                <label class="layui-form-label">牙齿咬合</label>
                                <div class="layui-input-block">
                                    <select name="city" id="occlusionTeeth" lay-filter="aihao">
                                        <option value="">请选择牙齿咬合</option>
                                        <option value="正常">正常</option>
                                        <option value="错齿">错齿</option>
                                    </select>
                                </div>
                            </div>
                        </td>
                        <td>
                            <div class="layui-form-item">
                                <label class="layui-form-label">毛发</label>
                                <div class="layui-input-block">
                                    <select name="city" id="sheepHair" lay-filter="aihao">
                                        <option value="">请选择毛发</option>
                                        <option value="1分">1分</option>
                                        <option value="2分">2分</option>
                                        <option value="3分">3分</option>
                                    </select>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="layui-form-item">
                                <label class="layui-form-label">色斑</label>
                                <div class="layui-input-block">
                                    <select name="city" id="sheepSpot" lay-filter="aihao">
                                        <option value="">请选择色斑</option>
                                        <option value="1分">1分</option>
                                        <option value="2分">2分</option>
                                        <option value="3分">3分</option>
                                    </select>
                                </div>
                            </div>
                        </td>
                        <td>
                            <div class="layui-form-item">
                                <label class="layui-form-label">蹄颜色</label>
                                <div class="layui-input-block">
                                    <select name="city" id="hoofolor" lay-filter="aihao">
                                        <option value="">请选择蹄颜色</option>
                                        <option value="1分">1分</option>
                                        <option value="2分">2分</option>
                                        <option value="3分">3分</option>
                                    </select>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="layui-form-item">
                                <label class="layui-form-label">嘴颜色</label>
                                <div class="layui-input-block">
                                    <select name="city" id="mouthColor" lay-filter="aihao">
                                        <option value="">请选择嘴颜色</option>
                                        <option value="1分">1分</option>
                                        <option value="2分">2分</option>
                                        <option value="3分">3分</option>
                                    </select>
                                </div>
                            </div>
                        </td>
                        <td>
                            <div class="layui-form-item">
                                <label class="layui-form-label">角</label>
                                <div class="layui-input-block">
                                    <select name="city" id="sheepAngle" lay-filter="aihao">
                                        <option value="">请选择角</option>
                                        <option value="有角">有角</option>
                                        <option value="无角">无角</option>
                                    </select>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="layui-form-item">
                                <label class="layui-form-label">脂肪分布</label>
                                <div class="layui-input-block">
                                    <select name="city" id="distributionFat" lay-filter="aihao">
                                        <option value="">请选择脂肪分布</option>
                                        <option value="1分">1分</option>
                                        <option value="2分">2分</option>
                                        <option value="3分">3分</option>
                                    </select>
                                </div>
                            </div>
                        </td>
                        <td></td>
                    </tr>
                </table>

                <div class="layui-form-item" style="float:right">
                    <button type="button" class="layui-btn layui-bg" onclick="Add()">保存</button>
                </div>



            </div>


        </div>
    </form>

    <!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
    <script src="//unpkg.com/layui@2.9.18/dist/layui.js"></script>

</body>

</html>

<script>
    var form = layui.form;
    var $ = layui.jquery;

    $(function () {
        bangsheng();
    })
    function bangsheng() {

        $.ajax({
            url: "http://localhost:5269/api/SheepArchive/SheepEarBuglesQuery",
            data: JSON.stringify({}),
            type: "post",
            async: false,
            dataType: "json",
            contentType: "application/json",
            success: res => {
                console.log(res)
                $.each(res.data, function () {
                    $("#earBugles").append(`<option value="${this.recordId}">${this.recordAuricle}</option>`);
                })
                form.render('select'); // 重新渲染下拉框

            }

        })
    }
    function Add() {

        var data = {
            sheepNumber: $("#earBugles").val(),
            currentDate: $("#currentDate").val(),
            occlusionTeeth: $("#occlusionTeeth").val(),
            sheepHair: $("#sheepHair").val(),
            sheepSpot: $("#sheepSpot").val(),
            hoofolor: $("#hoofolor").val(),
            mouthColor: $("#mouthColor").val(),
            sheepAngle: $("#sheepAngle").val(),
            distributionFat: $("#distributionFat").val()

            // flatId: '',
        }
        console.log(data)
        $.ajax({
            url: "http://localhost:5269/api/SheepArchive/PhaseDeterminationCreate",
            type: 'post',
            data: JSON.stringify(data),
            dataType: "json",
            contentType: "application/json",
            success: res => {
                if (res.code == 0) {
                    layer.msg(res.msg);
                    location.href = "/Breesing/Appearance";
                }
                else {
                    layer.msg(res.msg);
                }
            }
        })
    }


</script>
